/******************************************
@Description:确认消费-风控数据统计
交换机=consume.relationlogid
@Time : 2020/11/16 16:45
@Author :lixiaojun

*******************************************/
package main

import (
	"context"
	"git.900sui.cn/kc/base/utils"
	"git.900sui.cn/kc/kcgin"
	"git.900sui.cn/kc/kcgin/logs"
	"git.900sui.cn/kc/rabbitmq"
	"strconv"

	risk2 "git.900sui.cn/kc/rpcinterface/client/risk"
	"github.com/streadway/amqp"
)

func main() {
	rpcRisk := new(risk2.BusBasicMonth).Init()
	defer rpcRisk.Close()

	logs.Info("Environment Variable:MSF_ENV:", kcgin.KcConfig.RunMode)
	new(utils.KcLog).GetInstance(kcgin.AppConfig.String("risk.log.riskStatisticsConsume"))

	err := rabbitmq.Rabbitmq.Consume(kcgin.AppConfig.String("risk.queue.riskStatisticsConsume"), func(msg amqp.Delivery) {
		consumeLogId, _ := strconv.Atoi(string(msg.Body))
		var reply bool
		err := rpcRisk.RiskStatisticsConsume(context.Background(), &consumeLogId, &reply)
		if err != nil {
			utils.Logerr.Printf("消费成功后，risk风控数据统计任务执行失败，orderSn:%d, err:%s", consumeLogId, err)
		}
	})

	if err != nil {
		utils.Logerr.Printf("消费成功后,risk风控数据统计任务执行错误, err: %s", err.Error())
	}
}
